import React from "react";
import { Button } from "antd";
import dictTag from "@/component/Dict-Tag/Dict-Tag";
import { DICT_TYPE } from "@/utils/dict";

/**@description 列表表格字段 */
const getColumns = ({ open = Function, handleDelete = Function }) => {
    const columns = [
        {
            title: "类目名称",
            key: "className",
            dataIndex: "className",
            width: 180,
            ellipsis: true
        },
        {
            title: "品牌数量",
            key: "brandCount",
            dataIndex: "brandCount",
            width: 180,
            ellipsis: true
        },
        {
            title: "商品数量",
            key: "productCount",
            dataIndex: "productCount",
            width: 180,
            ellipsis: true
        },
        {
            title: "商家数量",
            key: "storeCount",
            dataIndex: "storeCount",
            width: 180,
            ellipsis: true
        },
        {
            title: "排序",
            key: "sort",
            dataIndex: "sort",
            width: 80,
        },

        {
            title: "状态",
            key: "status",
            dataIndex: "status",
            width: 80,
            render: (value, record) => dictTag({
                type: DICT_TYPE.COMMON_STATUS,
                value: value
            })
        },
        {
            title: "操作",
            key: "action",
            dataIndex: "action",
            width: 200,
            render: (text, record) => {
                return (
                    <>
                        <Button type="link" onClick={() => open("update", record)}>修改</Button>
                        <Button type="link" onClick={() => open("add", record.id, record.id, record.id)}>新增</Button>
                        <Button type="link" danger onClick={() => handleDelete(record)}>删除</Button>
                    </>
                )
            }
        },
    ];
    return columns;
}

export default getColumns;